home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / util / thedit20.zip / total.the < prev    next >
Text File  |  1995-01-26  |  1KB  |  50 lines

  1. /*
  2. $Id: TOTAL.THE 2.0 1995/01/26 16:34:42 MH Release MH $
  3. */
  4. /***********************************************************************/
  5. /* Description: REXX macro to sum numbers in a marked block.           */
  6. /* Syntax:      total                                                  */
  7. /* Notes:       This macro will sum the numbers in the marked block    */
  8. /*              and insert a new line with the total at the end of the */
  9. /*              block.                                                 */
  10. /***********************************************************************/
  11. Trace o
  12. 'EXTRACT /BLOCK/FNAME/FPATH/'
  13. If block.0 = 1 Then Do
  14.    'EMSG No Marked block'
  15.    Return
  16.    End
  17. If block.1 \= 'BOX' & block.1 \= 'COLUMN' Then Do
  18.    'EMSG No Marked BOX or COLUMN block'
  19.    Return
  20.    End
  21. current_file = fpath.1||fname.1
  22. If current_file \= block.6 Then Do
  23.    'EMSG Marked block not in current file'
  24.    Return
  25.    End
  26. Do i = block.2 To block.4
  27.    'NOMSG :'||i
  28.    If rc = 0 Then Leave
  29. End
  30. tot. = 0
  31. Do Forever
  32.    'EXTRACT /CURLINE/LINE/EOF'
  33.    If line.1 > block.4 Then Leave
  34.    If eof.1 = 'YES' Then Leave
  35.    num = Substr(curline.3,block.3,block.5-block.3+1)
  36.    Do i = 1 To Words(num)
  37.       If Datatype(Word(num,i),'NUM') Then tot.i = tot.i + Word(num,i)
  38.    End
  39.    if Words(num) > tot.0 Then tot.0 = Words(num)
  40.    'N'
  41. End
  42. 'U'
  43. line = ''
  44. Do i = 1 To tot.0
  45.    line = line tot.i
  46. End
  47. 'i' Copies(' ',block.3-1)||line
  48. 'N'
  49. Return
  50.